package com.epoint.mobileoa.bizlogic;

import java.util.HashMap;
import java.util.Map;

import com.epoint.mobileoa.service.MainService;
import com.epoint.mobileoa.tools.LogHelp;

import android.content.Intent;
import android.os.Message;

/**
 * @author liyc 
 * @time 2012-2-22 上午8:49:21
 * @annotation 任务处理基类，执行一个任务必须继承之
 */
@Deprecated
public abstract class Task {

	private Map<String,Object> param;
	private SuperView con;

	public Task(SuperView con,Map<String,Object> param) {
		
		this.param = param;
		this.con = con;
		
		boolean isServiceRuning = MainService.isServiceRunning(con, MainService.Name);
		
//		LogHelp.LogI("服务开启状态："+isServiceRuning);
		if (!isServiceRuning) {
//			LogHelp.Log2SDInfo("主服务重新启动");
			//启动服务
			Intent serviceIntent = new Intent(MainService.Name);
			con.startService(serviceIntent);
		}
		
	}

	public abstract void exectue(Message mess) throws Exception;

	public Map<String, Object> getParam() {
		return param;
	}

	public void setParam(HashMap<String, Object> param) {
		this.param = param;
	}

	public SuperView getCon() {
		return con;
	}

	public void setCon(SuperView con) {
		this.con = con;
	}

	public void setMessageToRefreshUI(Message mess,SuperView con,Object data){
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("context", con);
		map.put("data", data);
		mess.obj = map;
	}

	public String generateURL(String...param){
		return con.fp.generateUrl(param);
	}

	public FrameParam getFP(){
		return con.fp;
	}
	
}
